Page({

    data: {
        list: [],
        userID: null
    },
    
    onLoad () {
        let that = this;
        wx.getStorage({
            key: 'userID',
            success(res) {
                that.setData({
                    userID: res.data
                }) 
            }
        });
        let userId = this.data.userID;
        if (userId == null) {
            userId = getApp().globalData.userID
        }
        let Url = 'https://localhost:80/integralDetail/query/' + userId;
        wx.request({
            url: Url,
            method: 'get',
            header: {
                'content-type': 'application/json'
            },
            success: res => {
                console.log(res.data.rows[0].integralDetailDate);
                for (let i = 0; i < res.data.rows.length; i++)
                {
                    let date = res.data.rows[i].integralDetailDate;
                    let isIos = 0;
                    wx.getSystemInfo({
                        success (res) {
                        console.log(res.system);
                        let arr = res.system.split(' ');
                        if (arr[0] == 'iOS') {
                            isIos = 1;
                        }
                        console.log(arr[0]);
                        }
                    })
                    let timer;
                    if (isIos == 0) {
                        console.log('anzhuo');
                        console.log(date);
                        timer = new Date(date);
                        let y = timer.getFullYear();
                        let m = timer.getMonth()+1;
                        let d = timer.getDate();
                        let h = timer.getHours();
                        let mm = timer.getMinutes();
                        let s = timer.getSeconds();
                        console.log(m);
                        timer = y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + s;
                    } else {
                        console.log('ios');
                        console.log(date);            
                        let arr = date.split('T');
                        let dt = arr[0];
                        let darr = dt.split('-');
                        let t = arr[1];
                        let tarr = t.split('.000');
                        let marr = tarr[0].split(':');
                        marr[0] = parseInt(marr[0]);
                        darr[2] = parseInt(darr[2]);
                        console.log(typeof(darr[2]));
                        marr[0] = marr[0] + 8;
                        if (marr[0] >= 24) {
                        marr[0] = marr[0]%24;
                        darr[2] = darr[2]+1;
                        }
                        timer = parseInt(darr[0]) + '-' + parseInt(darr[1]) + '-' + parseInt(darr[2]) + ' ' + marr[0] + ':' + parseInt(marr[1]) + ':' + parseInt(marr[2]);            
                        console.log(timer);
                    }
                    res.data.rows[i].integralDetailDate = time;
                }     
                that.setData({
                    list: res.data.rows
                })
                console.log(that.data.list);
            }
        })
    }
})